'use strict';

const Service = require('egg').Service;

class BlogService extends Service {
    //添加
    async create(title,con,username) {
        let timer = new Date();
        await this.app.mysql.query('insert into bloglist (title,con,username,timer) values (?,?,?,?)',[title,con,username,timer])
    }
    //删除
    async destroy(id){
        await this.app.mysql.query('delete from bloglist where id=?',[id])
    }
    //更新
    async update(title,con,username,id){
        await this.app.mysql.query('update bloglist set title=?,con=?,username=? where id=?',[title,con,username,id])
    }
    //查询
    async index(){
        return await this.app.mysql.query('select * from bloglist')
    }
    //详情
    async show(id){
        return await this.app.mysql.query('select * from bloglist where id=?',[id])
    }
}

module.exports = BlogService;
